var CM_Function = new Object();
CM_Function.StringFormat = function(format) {

    var args = Array.prototype.slice.call(arguments, 1);
    var sprintfRegex = /\{(\d+)\}/g;

    var sprintf = function(match, number) {
        return number in args ? args[number] : match;
    };

    return format.replace(sprintfRegex, sprintf);
};

function SiteInfo(Team1Key, Team2Key, Team1Value, Team2Value) {
    this.Team1Key = Team1Key;
    this.Team2Key = Team2Key;
    this.Team1Value = Team1Value;
    this.Team2Value = Team2Value;
    this.Clone = function() {
        return new SiteInfo(this.Team1Key, this.Team2Key);
    };
}

function PairInfo(PairId, Sites) {
    this.PairId = PairId;
    this.Sites = Sites;
    this.Clone = function() {
        var sites = new Array();
        for (var i = 0; i < this.Sites.length; i++) {
            sites.push(this.Sites[i].Clone());
        }
        return new PairInfo(this.PairId, sites);
    };
}
function MatchInfo(MatchId, ATabId, ASiteType, BTabId, BSiteType, Pairs) {

    this.MatchId = MatchId;
    this.ATabId = ATabId;
    this.ASiteType = ASiteType;
    this.BTabId = BTabId;
    this.BSiteType = BSiteType;
    this.Pairs = Pairs;
    this.Clone = function() {
        var pairs = new Array();
        for (var i = 0; i < this.Pairs.length; i++) {
            pairs.push(this.Pairs[i].Clone());
        }
        return new PairInfo(this.MatchId, this.ATabId, this.ASiteType, this.BTabId, this.BSiteType, pairs);
    };
}
